import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path:'/login',
    name:'login',
    component:() => import('@/views/login')
  },
  {
    path:'/search',
    name:'search',
    component:() => import('@/views/search')
  },
  {
    path:'/article/:articleId',
    name:'article',
    component:() => import('@/views/article'),
    props:true //开启props传参，即将路由参数映射到组件的props数据中
  },
  {
    path:'/compile',
    name:'compile',
    component:() => import('@/views/compile')
  },
  {
    path:'/',
    //name:'layout',//如果父路由有默认子路由，那它的name就没有意义
    component:() => import('@/views/layout'),
    children:[
      {
        path:'/home', //默认子路由，只能有一个
        name:'home',
        component:() => import('@/views/home')
      },
      {
        path:'/mine',
        name:'mine',
        component:() => import('@/views/mine')
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
